/*
 * temperature.h
 *
 * Copyright 2011 Pieter Agten
 *
 * This file is part of Yarf.
 *
 * Yarf is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Yarf is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Yarf.  If not, see <http://www.gnu.org/licenses/>.
 */

/**
 * @file   temperature.h
 * @author Pieter Agten (pieter.agten@gmail.com)
 * @date   9 okt 2011
 * @brief  The temperature component manages the temperature of the nozzle 
 *         and the printbed.
 */

#ifndef TEMPERATURE_H_
#define TEMPERATURE_H_

#include <stdint.h>
#include <stdbool.h>

/**
 * Initializes the temperature component. The nozzle and printbed target 
 * temperatures are set to \a INITIAL_TARGET_TEMP_C.
 */
void temp_init(void);

/**
 * Sets the target temperature of the nozzle.
 *
 * @param c  the target temperature of the nozzle in degrees Celsius.
 */
void temp_set_nozzle_target(float c);

/**
 * Returns the last measured temperature of the nozzle in degrees Celsius.
 *
 * @return The last measured temperature of the nozzle in degrees Celsius.
 */
float temp_get_nozzle_temp(void);

/**
 * Returns the relative amount of power applied to the nozzle's heater.
 *
 * @return The relative amount of power applied to the nozzle's heater
 *         (0 to 255).
 */
uint8_t temp_get_nozzle_power(void);

/**
 * Returns whether the nozzle's target temperature has been reached.
 * 
 * @return True if the nozzle's target temperature has been reached and false
 *         otherwise.
 */
bool temp_nozzle_temperature_reached(void);

/**
 * Blocks until the nozzle's target temperature has been reached.
 */
void temp_nozzle_temperature_wait(void);



/**
 * Sets the target temperature of the printbed.
 *
 * @param c  the target temperature of the printbed in degrees Celsius.
 */
void temp_set_printbed_target(float c);

/**
 * Returns the last measured temperature of the printbed in degrees Celsius.
 *
 * @return The last measured temperature of the printbed in degrees Celsius.
 */
float temp_get_printbed_temp(void);

/**
 * Returns the relative amount of power applied to the printbed's heater.
 *
 * @return The relative amount of power applied to the printbed's heater
 *         (0 to 255).
 */
uint8_t temp_get_printbed_power(void);

/**
 * Returns whether the printbed's target temperature has been reached.
 * 
 * @return True if the printbed's target temperature has been reached and false
 *         otherwise.
 */
bool temp_printbed_temperature_reached(void);

/**
 * Blocks until the printbed's target temperature has been reached.
 */
void temp_printbed_temperature_wait(void);


#endif //TEMPERATURE_H_
